# -*- coding: utf8 -*-
# $Id :  $



# Copyright 2008-2010, Pascal Fautrero & JCharles
#
# This file is part of PyArchiver.
# 
# PyArchiver is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyArchiver is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyArchiver.  If not, see <http://www.gnu.org/licenses/>.



# Import packages

import wx                        # This module uses the new wx namespace
import sys
import os
import html_window
# import images                  # For PyEmbeddedImage

_ = wx.GetTranslation            # Define _ or add _ to builtins in your app file

appDir = os.path.split(os.path.abspath(sys.argv[0]))[0]

#---------------------------------------------------------------------------
        
class My_AboutNotebook(wx.Dialog):
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1,
                           title=_("About..."), size=(500, 400))
        
        # Bind the close event to an events handler
        self.Bind(wx.EVT_CLOSE, self.on_close_window)
        
        #-------------------------------------------------------------------

        # Simplified init method
        self.create_widget()
        self.do_layout()

        #-------------------------------------------------------------------
        
        self.CenterOnParent(wx.BOTH)
        print ""
        print "Display the about dialog"
        
        btnOK = self.ShowModal()
        
    #-----------------------------------------------------------------------

    def create_widget(self):         
        bitmapDir = os.path.join(appDir, "bitmaps")
        bmp = wx.Bitmap(os.path.join(bitmapDir, "copyright_Header.png"))
        # or PyEmbeddedImage
        # bmp = images.Copyright_Header.GetBitmap()
        self.img = wx.StaticBitmap(self, -1)
        self.img.SetBitmap(bmp)
        
        #-------------------------------------------------------------------
        
        self.notebook = wx.Notebook(self, style=wx.BK_DEFAULT)
        
        page1 = html_window.PageCopyright(self.notebook)
        page2 = html_window.PageLicence(self.notebook)
        page3 = html_window.PageDevelopers(self.notebook)
        page4 = html_window.PageContributors(self.notebook)
        page5 = html_window.PageSytemInfo(self.notebook)
        
        self.notebook.AddPage(page1, _("Copyright"))
        self.notebook.AddPage(page2, _("License"))
        self.notebook.AddPage(page3, _("Developers"))
        self.notebook.AddPage(page4, _("Contributors"))
        self.notebook.AddPage(page5, _("System"))

        # Bind some events to an events handler
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_page_changed)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.on_page_changing)
        
        #-------------------------------------------------------------------
        
        self.btnOK = wx.Button(self, id=wx.ID_CLOSE, label="")
        
        # Bind the button event to an events handler
        self.Bind(wx.EVT_BUTTON, self.on_ok, self.btnOK)

        self.btnOK.SetFocus()
        
    #-----------------------------------------------------------------------

    def do_layout(self):         
        imgSizer = wx.BoxSizer(wx.VERTICAL)
        ntbSizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.VERTICAL)
        
        #------------
        
        imgSizer.Add(self.img, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL)
        ntbSizer.Add(self.notebook, 1, wx.TOP | wx.EXPAND, 15)
        btnSizer.Add(self.btnOK, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 10)
        
        #------------
        
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(imgSizer, 0, wx.EXPAND, 0)        
        mainSizer.Add(ntbSizer, 1, wx.EXPAND, 0)
        mainSizer.Add(btnSizer, 0, wx.ALIGN_RIGHT)
        
        #------------
        
        self.SetAutoLayout(True)
        self.SetSizer(mainSizer)
        
    #-----------------------------------------------------------------------

    def on_page_changed(self, event):
        old = event.GetOldSelection()
        new = event.GetSelection()
        sel = self.notebook.GetSelection()
        event.Skip()


    def on_page_changing(self, event):
        old = event.GetOldSelection()
        new = event.GetSelection()
        sel = self.notebook.GetSelection()
        event.Skip()

        
    def on_close_window(self, event):
        self.Destroy()
        
        
    def on_ok(self, event):
        self.EndModal(False)


